home *** CD-ROM | disk | FTP | other *** search
/ Mac-Source 1994 July / Mac-Source_July_1994.iso / C and C++ / Entertainment / MacMud / Mud 4.0 / mud_simul.c < prev    next >
Encoding:
C/C++ Source or Header  |  1992-09-30  |  2.7 KB  |  118 lines  |  [TEXT/MPS ]

  1. /*
  2.  * This is a mudlib file. Copy it to /obj/simul_efun.c, or
  3.  * wherever the get_simul_efun() in master.c says.
  4.  * The functions defined in this file should only be replacements of efuns
  5.  * no longer supported. Don't use these functions any longer, use the
  6.  * replacement instead.
  7.  */
  8.  
  9. #pragma strict_types
  10. #pragma save_types
  11.  
  12. #if 0
  13. /*
  14.  * The ls() function is no longer needed, as get_dir() can do the same
  15.  * work.
  16.  */
  17. void ls(string path) {
  18.     int max, i, len, tmp;
  19.     status trunc_flag;
  20.     string *dir;
  21. #ifndef COMPAT_FLAG
  22.     seteuid(geteuid(previous_object()));
  23. #endif
  24. /*    dir = efun::get_dir(path);  crashes the gd -- demos 911115 */
  25.     dir = get_dir (path);
  26. #ifdef COMPAT_FLAG
  27.     if (path[0] == '/')
  28.     path = extract(path, 1);
  29.     if (path != "")
  30.     path += "/";
  31. #else
  32.     if (path != "/")
  33.     path += "/";
  34. #endif
  35.     if (!dir) {
  36.         write("No such directory.\n");
  37.         return;
  38.     }
  39.     if (sizeof(dir) > 330)
  40.     {
  41.         dir = dir[0..329];
  42.         trunc_flag = 1;
  43.     }
  44.     for (i=0; i < sizeof(dir); i++) {
  45.     if (file_size(path + "/" + dir[i]) == -2)
  46.             dir[i]+="/";
  47.         len = strlen(dir[i]);
  48.         if (len >= max)
  49.             max = len+1;
  50.     }
  51.     if (max > 79)
  52.         max = 79;
  53.     for (i=0; i < sizeof(dir); i++) {
  54.     string name;
  55.             name = dir[i];
  56.     tmp = strlen(name);
  57.     if (len + tmp > 79) {
  58.         len = 0;
  59.         write("\n");
  60.     }
  61.     write(name);
  62.         if (len + max > 80) {
  63.             write("\n");
  64.             len = 0;
  65.         } else {
  66.             write(extract(
  67. "                                                                                ",
  68.                 80-max+tmp));
  69.             len += max;
  70.         }
  71.     }
  72.     write("\n");
  73.     if (trunc_flag) write("***TRUNCATED***\n");
  74. }
  75. #endif
  76.  
  77. /*
  78.  * The old 'slice_array' is no longer needed. Use range argument inside
  79.  * a pair of brackets instead.
  80.  */
  81. mixed *slice_array(mixed *arr, int from, int to) {
  82.     return arr[from..to];
  83. }
  84.  
  85. /*
  86.  * filter_objects() has been renamed to filter_array().
  87.  */
  88. mixed *filter_objects(mixed *list, string str, object ob, mixed extra) {
  89.     return filter_array(list, str, ob, extra);
  90. }
  91.  
  92. /*
  93.  * query_snoop(). The old version had become somewhat to LPC-ish to
  94.  * put in the GD, and is is not used that much (of course, the extra
  95.  * check for the cloner does remain in the GD) - Zappa
  96.  */
  97.  
  98. object query_snoop(object ob)
  99. {
  100.     int cg_level, victim_level;
  101.     object snooper;
  102.  
  103.     if (!living(ob) || !query_ip_number(ob))
  104.     return 0;
  105.     cg_level = (int) this_player()->query_level();
  106.     victim_level = (int) ob->query_level();
  107.     if (!victim_level || !cg_level)
  108.     return 0;
  109.     if (cg_level <= victim_level)
  110.     return 0;
  111.     snooper = efun::query_snoop(ob);
  112.     if (!snooper)
  113.     return 0;
  114.     if (snooper->query_arch() && cg_level < (int) snooper->query_level())
  115.     return 0;
  116.     return snooper;
  117. }
  118.